package game.graphics;

import java.awt.Color;
import java.awt.Graphics;

import datastructures.Edge;

/**
 * @author Fredrik
 *
 */
public class GEdge {
	private Edge edge;
	private Color color = Color.BLACK;
	private boolean editingMode = false;
	
	/**
	 * Creates a new graphic edge
	 * @param e
	 */
	public GEdge(Edge e){
		this.edge = e;
	}
	
	/**
	 * Paint this edge on the Graphics g
	 * @param g
	 */
	public void paint(Graphics g){
		if(this.editingMode || this.edge.isVisible()){
			g.setColor(this.color);
			g.drawLine(getLeftX(), getLeftY(), getRightX(), getRightY());		
		}
	}
	
	/**
	 * Set to true if you are in editing mode and want the edge to be visible
	 * @param b
	 */
	public void setIsEditing(boolean b){
		this.editingMode = b;
	}

	private int getRightY() {
		return this.edge.getRightWord().getCordinates().getY();
	}

	private int getRightX() {
		return this.edge.getRightWord().getCordinates().getX();
	}

	private int getLeftY() {
		return this.edge.getLeftWord().getCordinates().getY();
	}

	private int getLeftX() {
		return this.edge.getLeftWord().getCordinates().getX();
	}

}
